home *** CD-ROM | disk | FTP | other *** search
- #define AEHANDLER_C
- #include "AEHandler.h"
-
-
- #if defined(__MWERKS__)
- #pragma segment __%Main
- #else
- #pragma segment Main
- #endif
-
-
- #define kReplyPref (kAEWaitReply | kAEAlwaysInteract | kAECanSwitchLayer)
- #define kTimeOut 200
-
-
- AEIdleUPP idleUPP = 0;
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AEOpenApplicationHandler (AppleEvent * message, long refCon)
- #else
- AEOpenApplicationHandler (AppleEvent *, long)
- #endif
- {
- InitRules();
- InitGame();
- ShowWindow (gAbaloneWindow);
- return noErr;
- }
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AEOpenDocumentsHandler (AppleEvent *message, long refCon)
- #else
- AEOpenDocumentsHandler (AppleEvent *message, long)
- #endif
- {
- OSErr error;
- AEKeyword keyword;
- DescType realType;
- AEDescList docList;
- long items;
- Size realSize;
- FSSpec specification;
-
- error = AEGetParamDesc (message, keyDirectObject, typeAEList, & docList);
-
- if (error == noErr)
- {
- error = AECountItems (& docList, & items);
-
- if (items > 1 && error == noErr)
- Warning (ONE_FILE_ONLY);
- }
- if (error == noErr)
- error = AEGetNthPtr (& docList, 1, typeFSS, & keyword, & realType, (Ptr) & specification, sizeof (FSSpec), & realSize);
-
- // In case an Open Documents event is generated, the Open Application event is NOT,
- // (this WAS a real surprise to me)
- // so the same code as in AEOpenApplicationHandler should appear here as well
-
- InitRules();
-
- if (error != noErr)
- InitGame();
- else
- OpenGameSpec (& specification);
-
- ShowWindow (gAbaloneWindow);
-
- AEDisposeDesc (& docList);
-
- return noErr;
- }
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AEPrintDocumentsHandler (AppleEvent *message, long refCon)
- #else
- AEPrintDocumentsHandler (AppleEvent *, long)
- #endif
- {
- Warning (PRINTING_NOT_IMPLEMENTED);
- return noErr;
- }
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AEQuitApplicationHandler (AppleEvent *message, long refCon)
- #else
- AEQuitApplicationHandler (AppleEvent *, long)
- #endif
- {
- Terminate();
- return noErr;
- }
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AbaloneMoveHandler (AppleEvent *message, AppleEvent *reply, long refCon)
- #else
- AbaloneMoveHandler (AppleEvent *message, AppleEvent *, long)
- #endif
- {
- OSErr error;
- MoveData move;
- long chck;
- short plyr;
- DescType realType;
- Size realSize;
-
- error = AEGetParamPtr (message, kSendMove, typeMove, & realType, (Ptr) & move, sizeof (long), & realSize);
- if (error == noErr)
- {
- // Assert (realType == typeMove, INTERNAL_ERROR);
- error = AEGetParamPtr (message, kSendPlyr, typePlyr, & realType, (Ptr) & plyr, sizeof (short), & realSize);
- }
- if (error == noErr)
- {
- // Assert (realType == typePlyr, INTERNAL_ERROR);
- error = AEGetParamPtr (message, kSendChck, typeChck, & realType, (Ptr) & chck, sizeof (long), & realSize);
- }
- if (error == noErr)
- {
- // Assert (realType == typeChck, INTERNAL_ERROR);
- }
- if (move == gLastMove)
- {
- return duplicateMoveErr;
- }
- if (chck != CheckSum (CurrentBoard()) && chck != CheckSum (RecentBoard()))
- {
- return outOfSyncErr;
- }
- if (! ProcessMove (move, true))
- {
- return illegalMoveErr;
- }
- return error;
- }
-
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AbaloneGameHandler (AppleEvent *message, AppleEvent *reply, long refCon)
- #else
- AbaloneGameHandler (AppleEvent *message, AppleEvent *reply, long)
- #endif
- {
- OSErr error;
- DescType realType;
- Size realSize;
- Game otherGame;
- Board otherBoard;
-
-
- error = AEGetParamPtr ( message,
- kSendGame,
- typeGame,
- & realType,
- (Ptr) & otherGame,
- sizeof (Game),
- & realSize
- );
- if (realType != typeGame || realSize != sizeof (Game))
- {
- return missingDataErr;
- }
- error = AEGetParamPtr ( message,
- kSendBord,
- typeBord,
- & realType,
- (Ptr) & otherBoard,
- sizeof (Board),
- & realSize
- );
- if (realType != typeBord || realSize != sizeof (Board))
- {
- return missingDataErr;
- }
- if ( CheckSum (& otherBoard) != CheckSum (CurrentBoard()))
- {
- if (otherGame.CurrentMove < gTheGame.CurrentMove)
- {
- Warning (OUT_OF_SYNC);
-
- gTheGame = otherGame;
- CopyBoard (& otherBoard, CurrentBoard());
- gTheGame.Board = CurrentBoard();
- InvalBoard();
- }
- // else: the other side will do this
- }
- error = AEPutParamPtr (reply, kReplyBord, typeBord, (Ptr) CurrentBoard(), sizeof (Board));
- error = AEPutParamPtr (reply, kReplyGame, typeGame, (Ptr) & gTheGame, sizeof (Game));
-
- return error;
- }
-
-
-
- // The init handler takes care of the connection protocol.
- // The sender (the client) puts its settings in the message sent;
- // The receiver (the server) should use these settings to do the following:
- // - extract the senders address
- // - compute the settings the client should have for a successfull connection
- // - put the requested settings in the reply message
- //
- // The client will (or will not) receive the reply message.
- // With the reply message, it should do the following:
- // - extract the requested settings
- // - set its settings as requested (or send a 'quit' event to cancel).
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AbaloneInitHandler (AppleEvent *message, AppleEvent *reply, long refCon)
- #else
- AbaloneInitHandler (AppleEvent *message, AppleEvent *reply, long)
- #endif
- {
- OSErr error;
- AEAddressDesc clientAddress;
- DescType realType;
- Size realSize;
- Settings otherSettings;
- short p;
- long checkSum;
-
- error = AEGetParamPtr ( message,
- kSendSets,
- typeSets,
- & realType,
- (Ptr) & otherSettings,
- sizeof (Settings),
- & realSize
- );
- if (realType != typeSets || realSize != sizeof (Settings))
- {
- return missingDataErr;
- }
- // The clients settings are now known.
- // Match them with ours, and change the other sides settings (or ours) when needed.
-
- MatchSettings (& gSet, & otherSettings);
-
- // Get the clients address
-
- if (AEGetAttributeDesc (message, keyAddressAttr, typeWildCard, &clientAddress) != noErr)
- {
- return missingDataErr;
- }
-
- // Add the requested settings to the reply,
- // and assume our opponents does as requested.
-
- error = AEPutParamPtr (reply, kReplySet1, typeSets, (Ptr) & otherSettings, sizeof (Settings));
-
- // Add my own settings to the reply as well.
- // This makes the protocol a bit more symmetric: both parties get a look at both settings.
- // The 'unfair' part is we demand the other party to make almost all the adjustments.
-
- error = AEPutParamPtr (reply, kReplySet2, typeSets, (Ptr) & gSet, sizeof (Settings));
-
- // Add a checksum of the current game as well.
- // If we're out of sync, let the other party adjust his board.
- // Worse yet, let him figure out there's a problem at all.
-
- checkSum = CheckSum (CurrentBoard());
- error = AEPutParamPtr (reply, kReplyChck, typeChck, (Ptr) & checkSum, sizeof (long));
-
- // We have a valid address.
- // Use the clients address for all the players we know are over there.
-
- for (p = blak; p <= gSet.Players; p++)
- {
- if ( ! IsNetPlayer (& otherSettings, p))
- {
- SetNetAddress (& clientAddress, p);
- }
- }
-
- return noErr;
- }
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AbaloneNew1Handler (AppleEvent *message, AppleEvent *reply, long refCon)
- #else
- AbaloneNew1Handler (AppleEvent *message, AppleEvent *reply, long)
- #endif
- {
- OSErr error;
- AEAddressDesc clientAddress;
- DescType realType;
- Size realSize;
- Settings otherSettings;
- short p, q;
-
- error = AEGetParamPtr ( message,
- kSendSets,
- typeSets,
- & realType,
- (Ptr) & otherSettings,
- sizeof (Settings),
- & realSize
- );
- if (error || realType != typeSets || realSize != sizeof (Settings))
- {
- return missingDataErr;
- }
-
- // Get the clients address
-
- if (AEGetAttributeDesc (message, keyAddressAttr, typeWildCard, &clientAddress) != noErr)
- {
- return noConnectionErr;
- }
-
- // Since we're the only one receiving this connection,
- // we should broadcast an update of the net addresses.
-
- for (p = blak; p <= gSet.Players; p++)
- {
- if ( IsNetPlayer (& gSet, p) // player is on the net for us.
- && IsConnected (p) // we have a connection
- )
- {
- if (IsNetPlayer (& otherSettings, p))
- {
- // This is a net player for our client,
- // so our client will be interested in this address we have.
-
- SendAEAdrs (& clientAddress, GetNetAddress(p), p);
- }
- for (q = blak; q <= gSet.Players; q++)
- {
- // This is a net player for us, but not for our client,
- // so the other net players we know about will be interested.
-
- if ( IsNetPlayer (& gSet, q) // player is on the net for us.
- && ! IsNetPlayer (& otherSettings, q) // our client handles the player
- && p != q) // it's not the same player
- {
- SendAEAdrs (GetNetAddress(p), & clientAddress, q);
- }
- }
- }
- }
-
-
- // Add the requested settings to the reply,
- // and assume our opponents does as requested.
-
- error = AEPutParamPtr (reply, kReplySet1, typeSets, (Ptr) & otherSettings, sizeof (Settings));
-
- // Add my own settings to the reply as well.
- // This makes the protocol a bit more symmetric: both parties get a look at both settings.
- // The 'unfair' part is we demand the other party to make almost all the adjustments.
-
- error = AEPutParamPtr (reply, kReplySet2, typeSets, (Ptr) & gSet, sizeof (Settings));
-
- // Add the current game as well. If we're out of sync, let the other party adjust his board.
-
- error = AEPutParamPtr (reply, kReplyBord, typeBord, (Ptr) CurrentBoard(), sizeof (Board));
- error = AEPutParamPtr (reply, kReplyGame, typeGame, (Ptr) & gTheGame, sizeof (Game));
-
- return noErr;
- }
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AbaloneStopHandler (AppleEvent *message, AppleEvent *reply, long refCon)
- #else
- AbaloneStopHandler (AppleEvent *message, AppleEvent *, long)
- #endif
- {
- OSErr error;
- DescType realType;
- Size realSize;
- short quitter;
-
- // Nothing we can do except telling our side the other side has stopped,
- // and clearing the net address for this player of course.
-
- if (gQuitFlag) // never mind, we already knew.
- return noErr;
-
-
- error = AEGetParamPtr ( message,
- kSendPlyr,
- typePlyr,
- & realType,
- (Ptr)& quitter,
- sizeof (short),
- & realSize
- );
- if (realType != typePlyr || realSize != sizeof (short))
- {
- return missingDataErr;
- }
-
- // Assert (gSet.PlayerKind[quitter] == networkPlayer, INTERNAL_ERROR);
-
- CurrentCursor (arrowCursor);
- switch (Alert (401, nil))
- {
- case 1: // Take Over
- ClearNetAddress (quitter);
- SetPlayerKind (& gSet, quitter, macPlayer);
- break;
- case 2: // Just Wait
- // Make sure we really wait by forcing the first player to be a network player
- SetPlayerKind (& gSet, blak, networkPlayer);
- break;
- case 3: // Quit Game
- BreakConnections(); // to make things even worse for a third player
- Terminate();
- break;
- }
- return noErr;
- }
-
-
-
- OSErr
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- AbaloneAdrsHandler (AppleEvent *message, AppleEvent *reply, long refCon)
- #else
- AbaloneAdrsHandler (AppleEvent *message, AppleEvent *, long)
- #endif
- {
- OSErr error;
- DescType realType;
- Size realSize;
- short player;
- TargetID addressID;
- AEAddressDesc addressDesc;
-
- // Get the player ID. This is the player whose address we're about to receive.
-
- error = AEGetParamPtr ( message,
- kSendPlyr,
- typePlyr,
- & realType,
- (Ptr)& player,
- sizeof (short),
- & realSize
- );
- if (realType != typePlyr || realSize != sizeof (short))
- {
- return missingDataErr;
- }
- if (! IsNetPlayer (& gSet, player))
- {
- // Don't bother handling this.
- return error;
- }
- // Get the player address. It's send as a TargetID, so it needs to be converted.
-
- error = AEGetParamPtr ( message,
- kSendAdrs,
- typeAdrs,
- & realType,
- (Ptr)& addressID,
- sizeof (TargetID),
- & realSize
- );
- if (realType != typeAdrs || realSize != sizeof (TargetID))
- {
- return missingDataErr;
- }
-
- error = AECreateDesc(
- typeTargetID, /* Standard target descriptor type. */
- (Ptr)&addressID, /* The data for the descriptor. */
- sizeof(TargetID), /* Size of the data. */
- &addressDesc /* Wherefore art thou desc. */
- );
-
- SetNetAddress (& addressDesc, player);
-
- AEDisposeDesc (& addressDesc);
-
- return error;
- }
-
-
-
- pascal OSErr
- SendAEMove (AEAddressDesc *opponent, MovePtr move, short plyr, long chck)
- {
- AppleEvent moveEvent, moveReply;
- OSErr error, therror;
- DescType realType;
- long realSize;
-
- // *) IM VI Ch.6 p.19
- // 1) Create using AECreateAppleEvent;
- //
- AECreateAppleEvent ( kAbaloneEventClass,
- kSendMove,
- opponent,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- & moveEvent
- );
-
- // 2) Use Apple Event manager functions to add parameters
-
- AEPutParamPtr (& moveEvent, kSendMove, typeMove, (Ptr) move, sizeof (long));
- AEPutParamPtr (& moveEvent, kSendPlyr, typePlyr, (Ptr) & plyr, sizeof (short));
- AEPutParamPtr (& moveEvent, kSendChck, typeChck, (Ptr) & chck, sizeof (long));
-
- // 3) Call AESend
-
- if (idleUPP == 0) idleUPP = NewAEIdleProc (IdleTime);
-
- error = AESend ( & moveEvent,
- & moveReply,
- kReplyPref,
- kAENormalPriority,
- kTimeOut,
- (AEIdleUPP) idleUPP,
- 0L
- );
-
- // 5) Process the reply Apple event
- AEGetParamPtr ( & moveReply,
- keyErrorNumber,
- typeShortInteger,
- & realType,
- (Ptr) & therror,
- sizeof (OSErr),
- & realSize
- );
-
- // 4) Dispose of copies of descriptor records
-
- AEDisposeDesc (& moveEvent);
-
- // 6) Dispose of reply descriptor record
-
- AEDisposeDesc (& moveReply);
-
- return therror != noErr ? therror : error;
- }
-
-
-
- pascal OSErr
- SendAEGame ( AEAddressDesc *opponent,
- GamePtr game,
- #if defined (__SC__) || defined (THINK_C) || defined(powerc)
- BoardPtr board,
- #else
- BoardPtr,
- #endif
- GamePtr serverGame,
- BoardPtr serverBoard
- )
- {
- AppleEvent gameEvent, gameReply;
- OSErr error;
- DescType realType;
- long realSize;
-
- // Create the actual Apple Event.
- AECreateAppleEvent ( kAbaloneEventClass,
- kSendGame,
- opponent,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- & gameEvent
- );
- AEPutParamPtr (& gameEvent, kSendGame, typeGame, (Ptr) game, sizeof (Game));
- AEPutParamPtr (& gameEvent, kSendBord, typeBord, (Ptr) game->Board, sizeof (Board));
-
- if (idleUPP == 0) idleUPP = NewAEIdleProc (IdleTime);
-
- // Send the event
- error = AESend ( & gameEvent,
- & gameReply,
- kReplyPref,
- kAENormalPriority,
- kTimeOut,
- (AEIdleUPP) idleUPP,
- 0L
- );
-
- // Handle the reply event.
-
- // The server game
-
- error = AEGetParamPtr (& gameReply, kReplyGame, typeGame, & realType, (Ptr) serverGame, sizeof (Game), & realSize);
- if (realSize != sizeof (Game))
- {
- error = missingDataErr;
- goto CleanUpGame;
- }
-
- // The server board
-
- error = AEGetParamPtr ( & gameReply, kReplyBord, typeBord, & realType, (Ptr) serverBoard, sizeof (Board), & realSize);
- if (realSize != sizeof (Board))
- {
- error = missingDataErr;
- goto CleanUpGame;
- }
-
- CleanUpGame:
-
- // Dispose of copies of descriptor records
-
- AEDisposeDesc (& gameEvent);
-
- // Dispose of reply descriptor record and the parameter list.
-
- AEDisposeDesc (& gameReply);
-
- return error;
- }
-
-
-
- pascal OSErr
- SendAEInit (AEAddressDesc *opponent, SettingsPtr settings, SettingsPtr serverSettings, long *checkSum)
- {
- AppleEvent initEvent, initReply;
- OSErr error = noErr;
- DescType realType;
- long realSize;
-
-
- // Create the actual Apple Event.
- AECreateAppleEvent ( kAbaloneEventClass,
- kSendInit,
- opponent,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- & initEvent
- );
-
- // Add the settings to the message
- error = AEPutParamPtr (& initEvent, kSendSets, typeSets, (Ptr) settings, sizeof (Settings));
-
- if (idleUPP == 0) idleUPP = NewAEIdleProc (IdleTime);
-
- // Send the event
- error = AESend ( & initEvent,
- & initReply,
- kReplyPref,
- kAENormalPriority,
- kTimeOut,
- (AEIdleUPP) idleUPP,
- 0L
- );
-
- if (error != noErr)
- {
- error = noConnectionErr;
- goto CleanupInit;
- }
-
- // Handle the reply event.
-
- // 1. The requested settings
-
- error = AEGetParamPtr ( & initReply,
- kReplySet1,
- typeSets,
- & realType,
- (Ptr) settings,
- sizeof (Settings),
- & realSize
- );
- if (realSize != sizeof (Settings))
- {
- error = missingDataErr;
- goto CleanupInit;
- }
-
- // 2. The server settings
-
- error = AEGetParamPtr ( & initReply,
- kReplySet2,
- typeSets,
- & realType,
- (Ptr) serverSettings,
- sizeof (Settings),
- & realSize
- );
- if (realSize != sizeof (Settings))
- {
- error = missingDataErr;
- goto CleanupInit;
- }
-
- // 3. The server board checksum
-
- error = AEGetParamPtr ( & initReply,
- kReplyChck,
- typeChck,
- & realType,
- (Ptr) checkSum,
- sizeof (long),
- & realSize
- );
- if (realSize != sizeof (long))
- {
- error = missingDataErr;
- }
-
- // Dispose of all AE stuff we created
-
- CleanupInit:
-
- AEDisposeDesc (& initEvent);
- AEDisposeDesc (& initReply);
-
- return error;
- }
-
-
-
- pascal OSErr
- SendAENew1 (AEAddressDesc *opponent, SettingsPtr settings)
- {
- AppleEvent new1Event, new1Reply;
- OSErr error = noErr;
-
-
- // Create the actual Apple Event.
- AECreateAppleEvent ( kAbaloneEventClass,
- kSendNew1,
- opponent,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- & new1Event
- );
-
- // Add the settings to the message
- error = AEPutParamPtr (& new1Event, kSendSets, typeSets, (Ptr) settings, sizeof (Settings));
-
- if (idleUPP == 0) idleUPP = NewAEIdleProc (IdleTime);
-
- // Send the event
- error = AESend ( & new1Event,
- & new1Reply,
- kReplyPref,
- kAENormalPriority,
- kTimeOut,
- (AEIdleUPP) idleUPP,
- 0L
- );
-
- if (error != noErr)
- {
- error = noConnectionErr;
- }
-
- // Dispose of all AE stuff we created
-
- CleanupNew1:
-
- AEDisposeDesc (& new1Event);
- AEDisposeDesc (& new1Reply);
-
- return error;
- }
-
-
-
- pascal OSErr
- SendAEStop (AEAddressDesc *opponent, short quitter)
- {
-
- AppleEvent stopEvent, stopReply;
- OSErr error;
-
- // Create the actual Apple Event.
- AECreateAppleEvent ( kAbaloneEventClass,
- kSendStop,
- opponent,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- & stopEvent
- );
-
- // Add the quitting player to the message
- error = AEPutParamPtr (& stopEvent, kSendPlyr, typePlyr, (Ptr) & quitter, sizeof (short));
-
- // Send the event
- error = AESend ( & stopEvent,
- & stopReply,
- kAENoReply, // Not in this case, thank you
- kAENormalPriority,
- kTimeOut,
- 0L, // (AEIdleProcPtr) IdleTime,
- 0L
- );
-
- AEDisposeDesc (& stopReply);
-
- return error;
- }
-
-
-
- pascal OSErr
- SendAEAdrs (AEAddressDesc *opponent, AEAddressDesc *clientAddress, short player)
- {
- AppleEvent adrsEvent, adrsReply;
- OSErr error, therror = noErr;
- TargetID senderID;
-
- // Send the player at address 'opponent' the message that player 'player'
- // can be found at the address retrievable from addressID.
-
- AECreateAppleEvent ( kAbaloneEventClass,
- kSendAdrs,
- opponent,
- kAutoGenerateReturnID,
- kAnyTransactionID,
- & adrsEvent
- );
-
- // Try to extract the adress in a form it can be sent in to others.
-
- Assert (clientAddress->descriptorType == typeTargetID, INTERNAL_ERROR);
- senderID = **(TargetID **)(clientAddress->dataHandle);
-
- // Add the player and his address as the parameters
-
- AEPutParamPtr (& adrsEvent, kSendPlyr, typePlyr, (Ptr) & player, sizeof (short));
- AEPutParamPtr (& adrsEvent, kSendAdrs, typeAdrs, (Ptr) & senderID, sizeof (TargetID));
-
- // Send the message
-
- error = AESend ( & adrsEvent,
- & adrsReply,
- kAENoReply, // Not in this case, thank you
- kAENormalPriority,
- kTimeOut,
- 0L, // (AEIdleProcPtr) IdleTime,
- 0L
- );
-
- // Get the reply
-
- // Also when we don't want a reply?
-
- // AEGetParamPtr ( & adrsReply,
- // keyErrorNumber,
- // typeShortInteger,
- // & realType,
- // (Ptr) & therror,
- // sizeof (OSErr),
- // & realSize
- // );
-
- // Dispose of created descriptor records
-
- AEDisposeDesc (& adrsEvent);
- AEDisposeDesc (& adrsReply);
-
- return therror != noErr ? therror : error;
- }
-
-
-
- pascal OSErr
- DoAEOpenApplication (AppleEvent message, AppleEvent reply, long refcon)
- {
- OSErr error = AEOpenApplicationHandler (& message, refcon);
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- InitConnection();
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEQuitApplication (AppleEvent message, AppleEvent reply, long refcon)
- {
- OSErr error = AEQuitApplicationHandler (& message, refcon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEOpenDocuments (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AEOpenDocumentsHandler (& message, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- InitConnection();
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEPrintDocuments (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AEPrintDocumentsHandler (& message, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEMove (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AbaloneMoveHandler (& message, & reply, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEGame (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AbaloneGameHandler (& message, & reply, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEInit (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AbaloneInitHandler (& message, & reply, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAENew1 (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AbaloneNew1Handler (& message, & reply, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEStop (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AbaloneStopHandler (& message, & reply, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- DoAEAdrs (AppleEvent message, AppleEvent reply, long refCon)
- {
- OSErr error = AbaloneAdrsHandler (& message, & reply, refCon);
-
- AEPutParamPtr (&reply, keyErrorNumber, typeShortInteger, (Ptr) &error, sizeof (short));
-
- return error;
- }
-
-
-
- pascal OSErr
- GotRequiredParams (AppleEvent *message)
- {
- DescType realType;
- Size realSize;
- OSErr error = AEGetAttributePtr (message, keyMissedKeywordAttr, typeWildCard, & realType, nil, 0, & realSize);
-
- if (error == errAEDescNotFound)
- return noErr;
-
- return error == noErr ? errAEEventNotHandled : error;
- }
-